package com.huarui.receiptAddress.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.ewaf.framework.model.ListModel;
import org.ewaf.framework.service.BaseService;

import com.huarui.area.dao.IAreaDao;
import com.huarui.area.model.Area;
import com.huarui.receiptAddress.dao.IReceiptAddressDao;
import com.huarui.receiptAddress.model.ReceiptAddress;

public class ReceiptAddressService extends BaseService {

	private static final long serialVersionUID = 4052025482466106444L;
	
	private IAreaDao areaDao;

	
	 public void setAreaDao(IAreaDao areaDao) {
		this.areaDao = areaDao;
	}


	private IReceiptAddressDao getDao(){
		 return (IReceiptAddressDao) dao;
	 }

	 
	 @SuppressWarnings("unchecked")
	public ListModel queryReceiptAddressByCompanyId(Integer companyId,ListModel lm ){
		 
		 lm.setTotal(this.getDao().countByConditions(companyId));
			Map map=new HashMap<String, String>();
			map.put("companyId", companyId);
			map.put("orderBy", lm.getOrderBy());
			map.put("start", lm.getStart());
			map.put("pageSize", lm.getPageSize());
			map.put("desc", lm.isDesc());
		    List<ReceiptAddress>receiptAddressList =this.getDao().getReceiptAddressByCompanyId(map);
		    
		 /**   for(ReceiptAddress receiptAddress:receiptAddressList){
		    	
		    	Area area =(Area) areaDao.getById(receiptAddress.getAreaId());
		    	
		    	receiptAddress.setProvinceId(area.getProvinceId());
		    	receiptAddress.setCityId(area.getCityId());
		    	receiptAddress.setDistrictId(area.getDistrictId());
		    	
		    }*/		    
		    lm.setResult(receiptAddressList);
		    return lm  ;
		 
	 }
	 
	 @SuppressWarnings("unchecked")
	public ReceiptAddress  getReceiptAddressByAreaId(Map map){
		 
		 return this.getDao().getReceiptAddressByAreaId(map);
		 
	 }
}
